home *** CD-ROM | disk | FTP | other *** search
/ PC User 2002 April / Disc 2 / PCUSER0402D2.iso / software / utils / files / wincron.exe / data1.cab / Sample_Scripts / webcast.tg < prev    next >
Encoding:
Text File  |  2001-10-20  |  3.5 KB  |  120 lines

  1. ## WebCast.tg
  2. # Copy the file from SORUCE LOCATION to TEMP LOCATION
  3. # Then, crop and convert to JPG and leave in OUT_NAME
  4. # Finally FTP to remote website to DST_NAME
  5. ##
  6. # script assumes:
  7. # 1. SRC_DIR is set to a directory to look for .BMP files. Eg. "f:\"
  8. # 2. TEMP_NAME is set to a temp name for the file. Eg. "d:\imgstore\temp.bmp"
  9. # 3. OUT_NAME is set to a full output name. Eg. "d:\imgstore\out.jpg"
  10. # 4. DST_NAME is the output name on the remote ftp server. Eg. "pages/out.jpg"
  11. # 5. the environment variables: USER.SERVER, USER.USERID, and USER.PASSWORD are set elsewhere,
  12. #    perhaps in the global (computer) environment or the local environment of WinCron via 
  13. #    Config.tg or AutoRun.tg. You could also set them here in this this script or hard-code the 
  14. #    values passed to -ftp connect.
  15.  
  16. # WebCast
  17. {
  18.     -name WebCast 
  19.     -start 
  20.     
  21.     ###
  22.     # Copy the file from SORUCE LOCATION to remote (FTP) DESTINATION
  23.     # (I use two separate computers for this, but this need not be the case.)
  24.     # Then, crop and convert to JPG and leave in OUT_NAME
  25.     # Finally FTP to remote website to DST_NAME
  26.     ###
  27.  
  28.     ###
  29.     # setup source, destination and temp names
  30.     # You can either uncomment these lines or set these values in your 
  31.     # computer environment. I like to set them in my environment.
  32.     # SRC_DIR=f:\
  33.     # TEMP_NAME=d:\imgstore\temp.bmp
  34.     # OUT_NAME=d:\imgstore\out.jpg
  35.     # DST_NAME=pages/out.jpg
  36.     
  37.     # set up an error handler for file operations
  38.     -action -onerror file_operation_fail
  39.  
  40.     # supply input mask and output variable name
  41.     -action -set OP=getFile
  42.     -action -print trying to GET oldest filename from MASTER computer
  43.     -action -getFile -oldest "%SRC_DIR%*.bmp" FILE_NAME
  44.  
  45.     # move the file to a temp location
  46.     -action -set OP=move
  47.     -action -print Trying to move %FILE_NAME% to %TEMP_NAME%
  48.     -action -move %FILE_NAME% %TEMP_NAME%
  49.  
  50.     # read the dib
  51.     -action -set OP=dibRead    
  52.     -action -print Reading DIB %TEMP_NAME%
  53.     -action -img dibRead handle %TEMP_NAME%
  54.  
  55.     # crop the dib
  56.     -action -set OP=dibCrop
  57.     -action -print Cropping DIB %TEMP_NAME%
  58.     -action -img dibCrop handle 640 480
  59.  
  60.     # write the JPG file
  61.     -action -set OP=dibWriteJPG
  62.     -action -print Writing JPG %OUT_NAME%
  63.     -action -img dibWriteJPG handle %OUT_NAME%
  64.     
  65.     # free memory
  66.     -action -set OP=dibRelease
  67.     -action -print Freeing DIB memory
  68.     -action -img dibRelease handle
  69.  
  70.     # delete the temp file
  71.     -action -set OP=delete
  72.     -action -print Delete %TEMP_NAME%
  73.     -action -delete %TEMP_NAME%
  74.     
  75.     ##
  76.     # PUT OUT_NAME on the remote server
  77.     # 
  78.     -action -print connecting to remote ftp server
  79.     -action -onerror connect_fail
  80.     -action -ftp connect handle %USER.SERVER% 21 %USER.USERID% %USER.PASSWORD%
  81.     -action -print putting file on remote ftp server
  82.     -action -onerror operation_fail
  83.     -action -ftp put handle %OUT_NAME% %DST_NAME% 1
  84.     -action -ftp close handle 
  85.  
  86.     -action -delete %OUT_NAME% 
  87.     -action -print done!
  88.     -action -inc 0 0 1 0
  89. }
  90.  
  91. # file operation failed
  92. {
  93.     -name file_operation_fail
  94.     -action -print file operation %OP% failed
  95.     -action -print will try later
  96.     -action -return break
  97. }
  98.  
  99. # connection failed
  100. {
  101.     -name connect_fail
  102.     -action -print FTP open connection failed with error:
  103.     -action -print %TG.LAST_ERROR%
  104.     -action -print will try later
  105.     -action -delete %OUT_NAME% 
  106.     -action -return break
  107. }
  108.  
  109. # operation failed
  110. {
  111.     -name operation_fail
  112.     -action -print FTP put failed with error:
  113.     -action -print %TG.LAST_ERROR%
  114.     -action -print Closing connection...
  115.     -action -ftp close handle
  116.     -action -print will try later
  117.     -action -delete %OUT_NAME% 
  118.     -action -return break
  119. }
  120.